#pragma once
#include <QObject>
#include <QList>
#include <QPointF>

// 前向声明
class BasePort;
class Connection;

class PortManager : public QObject
{
    Q_OBJECT

public:
    explicit PortManager(QObject *parent = nullptr);
    virtual ~PortManager();

    // 连接管理
    Connection* connectPorts(BasePort* startPort, BasePort* endPort);
    void disconnectPorts(BasePort* startPort, BasePort* endPort);
    void removeConnection(Connection* connection);
    
    // 获取连接
    QList<Connection*> getConnections() const { return m_connections; }
    Connection* getConnection(BasePort* startPort, BasePort* endPort) const;
    
    // 数据传输
    void transmitAllData();

private:
    QList<Connection*> m_connections;  // 所有连接
};